home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / 32BIT_QD._FO next >
Text File  |  1989-10-26  |  13KB  |  415 lines

  1. Topic   7:  Need some development pointers or    HELP!!!
  2. # 96: brian (bhamlin)      Wed, Oct 25, '89  (23:57)     366 lines
  3.  
  4.  Sure ! The following is an adaptaion of the latest MPW
  5.  headers....
  6.  
  7.  /* let's get a real juicy 32bit discussion going based
  8.    on this maybe !! */
  9.  
  10.  
  11.  
  12.  #ifndef _QuickDraw32Bit_
  13.  #define _QuickDraw32Bit_
  14.  
  15.  #ifndef _Quickdraw_
  16.  #include <Quickdraw.h>
  17.  #endif
  18.  
  19.  #ifndef _Color_
  20.  #include <Color.h>
  21.  #endif
  22.  
  23.  /* New Constants for 32-Bit QuickDraw */
  24.  
  25.  #define ditherCopy 64                  /* Dither mode for Copybits */
  26.  #define RGBDirect 16                   /* 16 & 32 bits/pixel pixelType value */
  27.  
  28.  
  29.  /* New error codes */
  30.  
  31.  #define rgnOverflowErr -147            /* Region accumulation failed. Resultinn
  32.  may be currupt */
  33.  #define pixmapTooDeepErr -148  /* Pixmap is not 1-bit/pixel for BitmapToRegion
  34.  */
  35.  #define insufficientStackErr -149 /* QuickDraw could not complete the operation
  36.  */
  37.  #define cDepthErr -157                 /* invalid pixel depth passed to NewGWor
  38.  UpdateGWorld */
  39.  
  40.  
  41.  #define        pixPurgeMask                    1
  42.  #define        noNewDeviceMask                 2
  43.  
  44.  /* Flag bits passed to or returned by Offscreen routines */
  45.  
  46.  enum  {
  47.         pixPurgeBit = 0,
  48.         nowNewDeviceBit = 1,
  49.         pixelsPurgeableBit = 6,
  50.         pixelsLockedBit = 7,
  51.  
  52.         mapPixBit = 16,                 /* set if color table mapping occurred /
  53.         newDepthBit = 17,                       /* set if pixels were scaled to/
  54.         alignPixBit = 18,                       /* set if pixels were realigned/
  55.         newRowBytesBit = 19,            /* set if pixmap was reconfigured in a /
  56.         reallocPixBit = 20,             /* set if offscreen buffer had to be re/
  57.         clipPixBit = 28,                        /* set if pixels were or are to/
  58.         stretchPixBit = 29,             /* set if pixels were or are to be stre/
  59.         ditherPixBit = 30,
  60.         gwFlagErrBit = 31
  61.  };
  62.  
  63.  typedef enum {
  64.         pixPurge = 1 << pixPurgeBit,
  65.         nowNewDevice = 1 << nowNewDeviceBit,
  66.         pixelsPurgeable = 1 << pixelsPurgeableBit,
  67.         pixelsLocked = 1 << pixelsLockedBit,
  68.         mapPix = 1 << mapPixBit,
  69.         newDepth = 1 << newDepthBit,
  70.         alignPix = 1 << alignPixBit,
  71.         newRowBytes = 1 << newRowBytesBit,
  72.         reallocPix = 1 << reallocPixBit,
  73.         clipPix = 1 << clipPixBit,
  74.         stretchPix = 1 << stretchPixBit,
  75.         ditherPix = 1 << ditherPixBit,
  76.         gwFlagErr = 1 << gwFlagErrBit
  77.  }GWorldFlag;
  78.  
  79.  typedef long GWorldFlags;
  80.  
  81.  /* Type definition of a GWorldPtr */
  82.  
  83.  typedef CGrafPtr GWorldPtr;
  84.  
  85.  
  86.  /*
  87.         Function Prototypes (necessary to get automatic type coercion -- see LSC
  88.  User's Manual p.125)
  89.  */
  90.  pascal OSErr           BitmapToRegion( RgnHandle, BitMap * );
  91.  pascal QDErr           NewGWorld( GWorldPtr *, short, Rect *, CTabHandle, GDHa,
  92.  GWorldFlags );
  93.  pascal Boolean         LockPixels( PixMapHandle );
  94.  pascal void                    UnlockPixels( PixMapHandle );
  95.  pascal GWorldFlags     UpdateGWorld( GWorldPtr *, short, Rect *, CTabHandle,
  96.  GDHandle, GWorldFlags );
  97.  pascal void            DisposeGWorld( GWorldPtr );
  98.  pascal void            GetGWorld( CGrafPtr *, GDHandle * );
  99.  pascal void            SetGWorld( CGrafPtr, GDHandle );
  100.  pascal void            CTabChanged( CTabHandle );
  101.  pascal void            PixPatChanged( PixPatHandle );
  102.  pascal void            PortChanged( GrafPtr );
  103.  pascal void            GDeviceChanged( GDHandle );
  104.  pascal void            AllowPurgePixels( PixMapHandle );
  105.  pascal void            NoPurgePixels( PixMapHandle );
  106.  pascal GWorldFlags     GetPixelsState( PixMapHandle );
  107.  pascal void                    SetPixelsState( PixMapHandle, GWorldFlags );
  108.  pascal Ptr                     GetPixBaseAddr( PixMapHandle );
  109.  pascal QDErr           NewScreenBuffer( Rect *, Boolean, GDHandle *, PixMapHan;
  110.  pascal void                    DisposeScreenBuffer( PixMapHandle );
  111.  pascal GDHandle                GetGWorldDevice( GWorldPtr );
  112.  
  113.  
  114.  pascal OSErr BitmapToRegion( region, bmap )
  115.         RgnHandle               region;
  116.         BitMap                  *bmap;
  117.  {
  118.         asm {
  119.                 SUBQ.L          #2,SP
  120.                 MOVE.L          region(A6),-(SP)
  121.                 MOVE.L          bmap(A6),-(SP)
  122.                 DC.W            0xA8D7
  123.                 MOVE.W          (SP)+,D0
  124.         }
  125.  }
  126.  
  127.  
  128.  pascal QDErr NewGWorld( offscreenGWorld, pixelDepth, boundsRect, cTable,
  129.  aGDevice, flags )
  130.         GWorldPtr               *offscreenGWorld;
  131.         short                   pixelDepth;
  132.         Rect                    *boundsRect;
  133.         CTabHandle              cTable;
  134.         GDHandle                aGDevice;
  135.         GWorldFlags             flags;
  136.  {
  137.         asm {
  138.                 SUBQ.L          #2,SP
  139.                 MOVE.L          offscreenGWorld(A6),-(SP)
  140.                 MOVE.W          pixelDepth(A6),-(SP)
  141.                 MOVE.L          boundsRect(A6),-(SP)
  142.                 MOVE.L          cTable(A6),-(SP)
  143.                 MOVE.L          aGDevice(A6),-(SP)
  144.                 MOVE.L          flags(A6),-(SP)
  145.                 MOVEQ           #0,D0
  146.                 DC.W            0xAB1D
  147.                 MOVE.W          (SP)+,D0
  148.         }
  149.  }
  150.  
  151.  pascal Boolean LockPixels( pm )
  152.         PixMapHandle    pm;
  153.  {
  154.         asm {
  155.                 SUBQ.L          #2,SP
  156.                 MOVE.L          pm(A6),-(SP)
  157.                 MOVEQ           #1,D0
  158.                 DC.W            0xAB1D
  159.                 MOVE.B          (SP)+,D0
  160.         }
  161.  }
  162.  
  163.  pascal void UnlockPixels( pm )
  164.         PixMapHandle    pm;
  165.  {
  166.         asm {
  167.                 MOVE.L          pm(A6),-(SP)
  168.                 MOVEQ           #2,D0
  169.                 DC.W            0xAB1D
  170.         }
  171.  }
  172.  
  173.  pascal GWorldFlags UpdateGWorld( offscreenGWorld, pixelDepth, boundsRect,
  174.  cTable, aGDevice, flags )
  175.         GWorldPtr               *offscreenGWorld;
  176.         short                   pixelDepth;
  177.         Rect                    *boundsRect;
  178.         CTabHandle              cTable;
  179.         GDHandle                aGDevice;
  180.         GWorldFlags             flags;
  181.  {
  182.         asm {
  183.                 SUBQ.L          #4,SP
  184.                 MOVE.L          offscreenGWorld(A6),-(SP)
  185.                 MOVE.W          pixelDepth(A6),-(SP)
  186.                 MOVE.L          boundsRect(A6),-(SP)
  187.                 MOVE.L          cTable(A6),-(SP)
  188.                 MOVE.L          aGDevice(A6),-(SP)
  189.                 MOVE.L          flags(A6),-(SP)
  190.                 MOVEQ           #3,D0
  191.                 DC.W            0xAB1D
  192.                 MOVE.L          (SP)+,D0
  193.         }
  194.  }
  195.  
  196.  pascal void DisposeGWorld( offscreenGWorld )
  197.         GWorldPtr               offscreenGWorld;
  198.  {
  199.         asm {
  200.                 MOVE.L          offscreenGWorld(A6),-(SP)
  201.                 MOVEQ           #4,D0
  202.                 DC.W            0xAB1D
  203.         }
  204.  }
  205.  
  206.  pascal void GetGWorld( port, gdh )
  207.         CGrafPtr                *port;
  208.         GDHandle                *gdh;
  209.  {
  210.         asm {
  211.                 MOVE.L          port(A6),-(SP)
  212.                 MOVE.L          gdh(A6),-(SP)
  213.                 MOVEQ           #5,D0
  214.                 DC.W            0xAB1D
  215.         }
  216.  }
  217.  
  218.  pascal void SetGWorld( port, gdh )
  219.         CGrafPtr                port;
  220.         GDHandle                gdh;
  221.  {
  222.         asm {
  223.                 MOVE.L          port(A6),-(SP)
  224.                 MOVE.L          gdh(A6),-(SP)
  225.                 MOVEQ           #6,D0
  226.                 DC.W            0xAB1D
  227.         }
  228.  }
  229.  
  230.  pascal void CTabChanged( ctab )
  231.         CTabHandle              ctab;
  232.  {
  233.         asm {
  234.                 MOVE.L          ctab(A6),-(SP)
  235.                 MOVEQ           #7,D0
  236.                 DC.W            0xAB1D
  237.         }
  238.  }
  239.  
  240.  pascal void PixPatChanged( ppat )
  241.         PixPatHandle    ppat;
  242.  {
  243.         asm {
  244.                 MOVE.L          ppat(A6),-(SP)
  245.                 MOVEQ           #8,D0
  246.                 DC.W            0xAB1D
  247.         }
  248.  }
  249.  
  250.  pascal void PortChanged( port )
  251.         GrafPtr                 port;
  252.  {
  253.         asm {
  254.                 MOVE.L          port(A6),-(SP)
  255.                 MOVEQ           #9,D0
  256.                 DC.W            0xAB1D
  257.         }
  258.  }
  259.  
  260.  pascal void GDeviceChanged( gdh )
  261.         GDHandle                gdh;
  262.  {
  263.         asm {
  264.                 MOVE.L          gdh(A6),-(SP)
  265.                 MOVEQ           #0x0A,D0
  266.                 DC.W            0xAB1D
  267.         }
  268.  }
  269.  
  270.  pascal void AllowPurgePixels( pm )
  271.         PixMapHandle    pm;
  272.  {
  273.         asm {
  274.                 MOVE.L          pm(A6),-(SP)
  275.                 MOVEQ           #0x0B,D0
  276.                 DC.W            0xAB1D
  277.         }
  278.  }
  279.  
  280.  pascal void NoPurgePixels( pm )
  281.         PixMapHandle    pm;
  282.  {
  283.         asm {
  284.                 MOVE.L          pm(A6),-(SP)
  285.                 MOVEQ           #0x0C,D0
  286.                 DC.W            0xAB1D
  287.         }
  288.  }
  289.  
  290.  pascal GWorldFlags GetPixelsState( pm )
  291.         PixMapHandle     pm;
  292.  {
  293.         asm {
  294.                 SUBQ.L          #4,SP
  295.                 MOVE.L          pm(A6),-(SP)
  296.                 MOVEQ           #0x0D,D0
  297.                 DC.W            0xAB1D
  298.                 MOVE.L          (SP)+,D0
  299.         }
  300.  }
  301.  
  302.  pascal void SetPixelsState( pm, state )
  303.         PixMapHandle    pm;
  304.         GWorldFlags     state;
  305.  {
  306.         asm {
  307.                 MOVE.L          pm(A6),-(SP)
  308.                 MOVE.L          state(A6),-(SP)
  309.                 MOVEQ           #0x0E,D0
  310.                 DC.W            0xAB1D
  311.         }
  312.  }
  313.  
  314.  pascal Ptr GetPixBaseAddr( pm )
  315.         PixMapHandle    pm;
  316.  {
  317.         asm {
  318.                 SUBQ.L          #4,SP
  319.                 MOVE.L          pm(A6),-(SP)
  320.                 MOVEQ           #0x0F,D0
  321.                 DC.W            0xAB1D
  322.                 MOVE.L          (SP)+,D0
  323.         }
  324.  }
  325.  
  326.  pascal QDErr NewScreenBuffer( globalRect, purgeable, gdh, offscreenPixMap )
  327.         Rect                    *globalRect;
  328.         Boolean                 purgeable;
  329.         GDHandle                *gdh;
  330.         PixMapHandle    *offscreenPixMap;
  331.  {
  332.         asm {
  333.                 SUBQ.L          #2,SP
  334.                 MOVE.L          globalRect(A6),-(SP)
  335.                 MOVE.B          purgeable(A6),-(SP)
  336.                 MOVE.L          gdh(A6),-(SP)
  337.                 MOVE.L          offscreenPixMap(A6),-(SP)
  338.                 MOVEQ           #0x10,D0
  339.                 DC.W            0xAB1D
  340.                 MOVE.W          (SP),D0
  341.         }
  342.  }
  343.  
  344.  pascal void DisposeScreenBuffer( offscreenPixMap )
  345.         PixMapHandle    offscreenPixMap;
  346.  {
  347.         asm {
  348.                 MOVE.L          offscreenPixMap(A6),-(SP)
  349.                 MOVEQ           #0x11,D0
  350.                 DC.W            0xAB1D
  351.         }
  352.  }
  353.  
  354.  pascal GDHandle GetGWorldDevice( offscreenGWorld )
  355.         GWorldPtr               offscreenGWorld;
  356.  {
  357.         asm {
  358.                 SUBQ.L          #4,SP
  359.                 MOVE.L          offscreenGWorld(A6),-(SP)
  360.                 MOVEQ           #0x12,D0
  361.                 DC.W            0xAB1D
  362.                 MOVE.L          (SP)+,D0
  363.         }
  364.  }
  365.  
  366.  
  367.  #endif
  368.  
  369.  
  370.  
  371. Topic   7:  Need some development pointers or    HELP!!!
  372. # 97: brian (bhamlin)      Thu, Oct 26, '89  (00:10)      35 lines
  373.  
  374.    Drat !  (I think I screwed up the comments and long lines)
  375.  
  376.    for those in the crowd actually wanting to *use* this stuff,
  377.  here are the missing pieces, as it were.....
  378.  ]
  379.  
  380.      
  381.  -147 /* Region accumulation failed. Resulting region may be currupt */
  382.  -148 /* Pixmap is not 1-bit/pixel for BitmapToRegion */
  383.  -149 /* QuickDraw could not complete the operation */
  384.  -157 /* invalid pixel depth passed to NewGWorld or UpdateGWorld */
  385.  
  386.  
  387.  /*
  388.         Function Prototypes (necessary to get automatic type coercion 
  389.         -- see LSC User's Manual p.125)
  390.  */
  391.  
  392.  NewGWorld( GWorldPtr *, short, Rect *, CTabHandle, GDHandle, GWorldFlags );
  393.  
  394.  UpdateGWorld( GWorldPtr *, short, Rect *, CTabHandle, GDHandle, GWorldFlags );
  395.  
  396.  
  397.  NewGWorld( offscreenGWorld, pixelDepth, boundsRect, cTable, aGDevice, flags )
  398.  
  399.  UpdateGWorld( offscreenGWorld, pixelDepth, boundsRect, cTable, aGDevice, flags
  400.  )
  401.  )
  402.  
  403.  /* I think that's it - check it out, write something fun. 
  404.      Remember: You don't have to have a 32bit video card,
  405.      just Sys 6.0.3 or greater on a color-capable machine
  406.      and the 32bit Quickdraw INIT in your system folder to 
  407.      use these calls ! 
  408.  */
  409.  
  410. Topic   7:  Need some development pointers or    HELP!!!
  411. # 98: brian (bhamlin)      Thu, Oct 26, '89  (01:56)       2 lines
  412.  
  413.  /* hoo-boy, well ANYWAY thanks to Sam Roberts for 
  414.       assembler tweaking. Other Than That, ga    */
  415.